R-Ladies DC Meetup
2024-07-11
A service from Amazon Web Services (AWS) that lets you run code in the cloud without having to manage servers.
You can think of it like a kitchen in a restaurant.
Focus on writing code, not managing infrastructure.
Define a custom runtime (through a container image) with R.
Define a custom runtime (through a container image) with R.
FROM public.ecr.aws/lambda/python:3.10
ENV R_VERSION=4.3.1
RUN yum -y install wget git tar openssl-devel libxml2-devel \
&& yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm \
&& wget https://cdn.rstudio.com/r/centos-7/pkgs/R-${R_VERSION}-1-1.x86_64.rpm \
&& yum -y install R-${R_VERSION}-1-1.x86_64.rpm \
&& rm R-${R_VERSION}-1-1.x86_64.rpm \
&& yum -y clean all \
&& rm -rf /var/cache/yum
ENV PATH="${PATH}:/opt/R/${R_VERSION}/bin/"
ENV LD_LIBRARY_PATH="/opt/R/${R_VERSION}/lib/R/lib/"
RUN R -e "install.packages(c('aws.s3', 'dplyr'), \
repos = c(CRAN = 'https://packagemanager.posit.co/cran/__linux__/centos7/latest'))"
COPY requirements.txt .
RUN pip3 install -r requirements.txt --target "${LAMBDA_TASK_ROOT}"
COPY . ${LAMBDA_TASK_ROOT} FROM public.ecr.aws/lambda/provided
ENV R_VERSION=4.0.3
ENV R_SCRIPT=app.R
RUN yum -y install wget git tar openssl-devel libxml2-devel \
&& yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm \
&& wget https://cdn.rstudio.com/r/centos-7/pkgs/R-${R_VERSION}-1-1.x86_64.rpm \
&& yum -y install R-${R_VERSION}-1-1.x86_64.rpm \
&& rm R-${R_VERSION}-1-1.x86_64.rpm \
&& yum -y clean all \
&& rm -rf /var/cache/yum
ENV PATH="${PATH}:/opt/R/${R_VERSION}/bin/"
RUN R -e "install.packages(c('aws.s3', 'dplyr', 'lambdr'), repos = 'https://cloud.r-project.org/')"
RUN mkdir /lambda
COPY ${R_SCRIPT} /lambda
RUN chmod 755 -R /lambda
RUN printf '#!/bin/sh\ncd /lambda\nRscript ${R_SCRIPT}' > /var/runtime/bootstrap \
&& chmod +x /var/runtime/bootstrap